<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="微社区,Q生活" name="keywords"/>
<meta content="微社区,Q生活" name="description"/>
<title>微社区|Q生活</title>
<link rel="stylesheet" href="${ctx }/static/css/Master.css"/>
<script src="${ctx }/static/js/jquery-1.9.0.min.js"></script>

<script src="${ctx}/static/plugins/layer/layer.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>

<script type="text/javascript">
$(function(){
	//查询公告列表
	$.ajax({    
	    url:"${ctx}/findSysAnnounce",   
	    data:"",    
	    type:"get",    
	    cache:false,    
	    dataType:"text",
	    async:true, //默认为true 异步    
	    global:false,//是否触发全局 AJAX 事件。默认值: true
	    success:function(data) {
	    	if(data){
	    		//替换数字为字符串(js数字类型存储java long类型 64位, 过长时会丢失精度)
		    	data = data.replace(/advId\":(\d+),/g,"advId\":\"$1\",");
		    	data = JSON.parse(data);
	    		var html = "";
	    		for ( var i = 0; i < data.length; i++) {
	    			if(i>4){
	    				break;
	    			}
					var item = data[i];
					if(i == 0){
						html += '<li class="hover" data-id="'+item.advId+'">';
						
						$("#advTitle").text(item.advTitle);
				  		$("#advDetails").text(item.advDetails);
				  		$("#goAdvDetails").attr("href","announce/"+item.advId+"/indexListDetails");
					}else{
						html += '<li data-id="'+item.advId+'">'
					}
					html += '<a href="javascript:void(0);">'+item.advTitle+'</a></li>';
				}
	    		
	        	$("#sysAnnounceList").children().remove();
	        	$("#sysAnnounceList").html(html);
	        	$("#goAdvList").show();
	        	$("#goAdvDetails").show();
	    	}
	     }  
	});
	
	//后台用户在线总数
	$.ajax({    
	    url:"${ctx}/monitor/online/sysUserCount",   
	    data:"",    
	    type:"get",    
	    cache:false,    
	    dataType:"json",
	    async:true, //默认为true 异步    
	    global:false,//是否触发全局 AJAX 事件。默认值: true
	    success:function(data) {
	        $("#sysUserCount").text(data);
	     }  
	});
	
	<shiro:hasPermission name="mycenter:audit:view">
	//根据当前登录用户获取待审核总条数的接口
	$.ajax({    
	    url:"${ctx}/findMyCountAudit",   
	    data:"",    
	    type:"get",    
	    cache:false,    
	    dataType:"json",
	    async:true, //默认为true 异步    
	    global:false,//是否触发全局 AJAX 事件。默认值: true
	    success:function(data) {
	        $("#myCountAudit").text(data);
	     }  
	});
	</shiro:hasPermission>
	
	//on动态绑定事件
	$("#sysAnnounceList").on("click","li", function(){
		var $this = $(this);
		var advId = $this.data("id");
		//查询公告详情
		$.ajax({    
		  url:"${ctx}/findSysAnnounceDetail?advId="+advId,   
		  data:{},    
		  type:"get",    
		  cache:false,    
		  dataType:"json",
		  async:true, //默认为true 异步    
		  global:false,//是否触发全局 AJAX 事件。默认值: true
		  success:function(data) {
		  	if(data){
		  		$("#sysAnnounceList li.hover").removeClass("hover");
		  		$this.addClass("hover");
		  		
		  		$("#advTitle").text(data.advTitle);
		  		$("#advDetails").text(data.advDetails);
		  		$("#goAdvDetails").attr("href","announce/"+advId+"/indexListDetails");
		  	}
		  }  
		});
	});

});

</script>
</head>

<body>
<section class="boxRight">
	<h3 class="t Index_t">欢迎使用Q生活后台管理系统</h3>
	<section class="databox clearfix">
	
		<section class="context Indexfirst IndexNotice">
			<h3 class="t" id="advTitle">暂无公告</h3>
			<article class="con">
				<p id="advDetails"></p>
			</article>
			<span class="r"><a href="javascript:void(0);" class="org" id="goAdvDetails" style="display: none;">查看详情 ></a></span>
		</section>
		
		<section class="context Indexfirst IndexNews">
			<ul id="sysAnnounceList">
			</ul>
			<span class="r"><a href="${ctx }/announce/indexAnnouceList" class="org" id="goAdvList" style="display: none;">查看全部 ></a></span>
		</section>
		
		<div class="context">
			<dl>
				<dt><span class="indexIcon peopleIcon"></span><p><strong class="red" id="sysUserCount">-</strong>人</p></dt>
				<dd>后台管理系统实时在线人数</dd>
			</dl>
			<%-- 
			<dl>
				<dt><span class="indexIcon peopleIcon"></span><p><strong class="red">-</strong>人</p></dt>
				<dd>APP实时在线人数</dd>
			</dl>
			--%>
		</div>
		<shiro:hasPermission name="mycenter:audit:view">
		<div class="context">
			<dl>
				<dt><span class="indexIcon listIcon"></span><p><strong class="red" id="myCountAudit">-</strong>条</p></dt>
				<dd>待审核记录</dd>
			</dl>
			<dl>
				<dt></dt>
				<dd><a href="${ctx }/audit/auditListNo" class="org">立即审核 ></a></dd>
			</dl>
		</div>
		</shiro:hasPermission>
		
		<%--
		<div class="context">
			<dl>
				<dt><span class="indexIcon msgIcon"></span><p><strong class="red">-</strong>条</p></dt>
				<dd>系统消息</dd>
			</dl>
			<dl>
				<dt></dt>
				<dd><a href="javascript:void(0);" class="org">立即查看 ></a></dd>
			</dl>
		</div>
		
		<div class="context">
			<dl>
				<dt><span class="indexIcon moneyIcon"></span><p><strong class="red">-</strong>元</p></dt>
				<dd>今天有<span class="red">-</span>笔交易</dd>
			</dl>
			<dl>
				<dt></dt>
				<dd><a href="javascript:void(0);" class="org">查看详细 ></a></dd>
			</dl>
		</div>
		
		<div class="context">
			<dl>
				<dt><span class="indexIcon moneyIcon"></span><p><strong class="red">-</strong>元</p></dt>
				<dd>截止到xxxx.xx.xx,x月份有<span class="red">-</span>笔交易</dd>
			</dl>
			<dl>
				<dt></dt>
				<dd><a href="javascript:void(0);" class="org">查看详细 ></a></dd>
			</dl>
		</div>--%>
	</section>
</section>
</body>
</html>